<?php
/**
 * Created by PhpStorm.
 * User: LiuJiaJun
 * Date: 2018/12/5
 * Time: 15:09
 */

namespace api\storage\model;

use think\Model;

class StorageModel extends Model
{
    protected $table = 'iwh_storage';
    protected $pk = 'uuid';

    /**
     * 根据uuid查询仓库信息
     *
     * @param string $uuid
     * @return array|false|\PDOStatement|string|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function findStorageByUuid($uuid = ''){
        return $this->where(['uuid'=>$uuid])->find();
    }


    /**
     * 更新bomUuid的信息
     *
     * @param null $bomUuid
     * @param $uuid
     * @return false|int
     */
    public function updateBomByUuid($bomUuid,$uuid){
        return $this->isUpdate(true)->save(['bom_uuid'=>$bomUuid],['uuid'=>$uuid]);
    }

    /**
     * 更新仓库的类型
     *
     * @param $type int 类型
     * @param $uuid string uuid
     * @return false|int
     */
    public function updateType($type,$uuid){
        return $this->isUpdate(true)->save(['type'=>$type],['uuid'=>$uuid]);
    }
}